/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

import com.beans.Prospects;
import com.metier.ProspectsMetier;

/**
 * 
 * @author moussa
 */
public class PanelModifierProspect extends javax.swing.JPanel {
	private String numeroCorrespondant;

	/**
	 * Creates new form PanelAjouterProspect
	 */
	public PanelModifierProspect() {
		// initComponents();
	}

	public PanelModifierProspect(JButton boutonAnnuler) {
		initComponents(boutonAnnuler);

	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed"
	// desc="Generated Code">//GEN-BEGIN:initComponents
	private void initComponents(JButton bouttonAnnuler) {

		jLabel1 = new javax.swing.JLabel();
		typeProspects = new javax.swing.JComboBox();
		jLabel2 = new javax.swing.JLabel();
		textNumero = new javax.swing.JTextField();
		jLabel3 = new javax.swing.JLabel();
		jScrollPane1 = new javax.swing.JScrollPane();
		texteCommentaire = new javax.swing.JTextArea();
		jLabel4 = new javax.swing.JLabel();
		dateCreateProspect = new com.toedter.calendar.JDateChooser();
		buttonValider = new javax.swing.JButton();
		buttonAnnuler = new javax.swing.JButton();

		setBackground(new java.awt.Color(128, 130, 133));
		setMaximumSize(new java.awt.Dimension(1050, 375));
		setMinimumSize(new java.awt.Dimension(1050, 375));
		setPreferredSize(new java.awt.Dimension(1050, 375));

		jLabel1.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
		jLabel1.setForeground(new java.awt.Color(255, 255, 255));
		jLabel1.setText("Type :");

		typeProspects.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
		typeProspects.setModel(new javax.swing.DefaultComboBoxModel(
				new String[] { "Demarche Physique", "Demarche Telephonique",
						"Maill" }));

		jLabel2.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
		jLabel2.setForeground(new java.awt.Color(255, 255, 255));
		jLabel2.setText("Numero :");

		jLabel3.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
		jLabel3.setForeground(new java.awt.Color(255, 255, 255));
		jLabel3.setText("Commentaire :");

		texteCommentaire.setColumns(20);
		texteCommentaire.setRows(5);
		jScrollPane1.setViewportView(texteCommentaire);

		jLabel4.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
		jLabel4.setForeground(new java.awt.Color(255, 255, 255));
		jLabel4.setText("Date Create :");

		buttonValider.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
		buttonValider.setText("VALIDER");
		buttonValider.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub

				if (JOptionPane.showConfirmDialog(getFrame(),
						"Voulez-vous vraiment confirmer la modification?",
						"Information", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
					ProspectsMetier prospectMetier = new ProspectsMetier();
					Prospects prospectToModify = new Prospects();
					String numeroProspectToModify = getNumeroCorrespondant();
					prospectToModify = prospectMetier
							.findProspectByNumero(numeroProspectToModify);
					prospectToModify.setPrsComent(texteCommentaire.getText());
					prospectToModify.setPrsNumero(textNumero.getText());
					prospectToModify.setPrsType((String) typeProspects
							.getSelectedItem());
					prospectToModify.setPrsDateCreate(dateCreateProspect
							.getDate());
					prospectMetier.testUpdate(prospectToModify);

					JOptionPane.showMessageDialog(null,
							" La modification a bien réussi");
					texteCommentaire.setText("");
					textNumero.setText("");
					dateCreateProspect.setDate(null);

				}
			}
		});

		buttonAnnuler.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
		buttonAnnuler.setText("Annuler");

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
		this.setLayout(layout);
		layout.setHorizontalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup()
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.LEADING)
												.addGroup(
														layout.createSequentialGroup()
																.addGap(47, 47,
																		47)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.LEADING)
																				.addComponent(
																						jLabel2)
																				.addComponent(
																						jLabel1))
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.LEADING,
																				false)
																				.addComponent(
																						typeProspects,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						195,
																						javax.swing.GroupLayout.PREFERRED_SIZE)
																				.addComponent(
																						textNumero))
																.addGap(357,
																		357,
																		357)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.LEADING)
																				.addComponent(
																						bouttonAnnuler)
																				.addGroup(
																						layout.createSequentialGroup()
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.LEADING)
																												.addComponent(
																														jLabel3)
																												.addComponent(
																														jLabel4))
																								.addGap(18,
																										18,
																										18)
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.LEADING)
																												.addComponent(
																														dateCreateProspect,
																														javax.swing.GroupLayout.PREFERRED_SIZE,
																														187,
																														javax.swing.GroupLayout.PREFERRED_SIZE)
																												.addComponent(
																														jScrollPane1,
																														javax.swing.GroupLayout.PREFERRED_SIZE,
																														187,
																														javax.swing.GroupLayout.PREFERRED_SIZE)))))
												.addGroup(
														layout.createSequentialGroup()
																.addGap(325,
																		325,
																		325)
																.addComponent(
																		buttonValider)))
								.addContainerGap(45, Short.MAX_VALUE)));
		layout.setVerticalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup()
								.addGap(48, 48, 48)
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.LEADING)
												.addComponent(
														jScrollPane1,
														javax.swing.GroupLayout.PREFERRED_SIZE,
														javax.swing.GroupLayout.DEFAULT_SIZE,
														javax.swing.GroupLayout.PREFERRED_SIZE)
												.addGroup(
														layout.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
																.addComponent(
																		jLabel2)
																.addComponent(
																		textNumero,
																		javax.swing.GroupLayout.PREFERRED_SIZE,
																		javax.swing.GroupLayout.DEFAULT_SIZE,
																		javax.swing.GroupLayout.PREFERRED_SIZE)
																.addComponent(
																		jLabel3)))
								.addGap(18, 18, 18)
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.BASELINE)
												.addComponent(jLabel1)
												.addComponent(
														typeProspects,
														javax.swing.GroupLayout.PREFERRED_SIZE,
														javax.swing.GroupLayout.DEFAULT_SIZE,
														javax.swing.GroupLayout.PREFERRED_SIZE))
								.addGap(5, 5, 5)
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.LEADING)
												.addGroup(
														layout.createSequentialGroup()
																.addComponent(
																		dateCreateProspect,
																		javax.swing.GroupLayout.PREFERRED_SIZE,
																		javax.swing.GroupLayout.DEFAULT_SIZE,
																		javax.swing.GroupLayout.PREFERRED_SIZE)
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED,
																		81,
																		Short.MAX_VALUE)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.BASELINE)
																				.addComponent(
																						buttonValider)
																				.addComponent(
																						bouttonAnnuler))
																.addGap(56, 56,
																		56))
												.addGroup(
														layout.createSequentialGroup()
																.addComponent(
																		jLabel4)
																.addContainerGap(
																		javax.swing.GroupLayout.DEFAULT_SIZE,
																		Short.MAX_VALUE)))));
	}// </editor-fold>//GEN-END:initComponents

	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JButton buttonAnnuler;
	private javax.swing.JButton buttonValider;
	private javax.swing.JComboBox typeProspects;
	private com.toedter.calendar.JDateChooser dateCreateProspect;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel2;

	public javax.swing.JComboBox getTypeProspects() {
		return typeProspects;
	}

	public void setTypeProspects(javax.swing.JComboBox typeProspects) {
		this.typeProspects = typeProspects;
	}

	public com.toedter.calendar.JDateChooser getDateCreateProspect() {
		return dateCreateProspect;
	}

	public void setDateCreateProspect(
			com.toedter.calendar.JDateChooser dateCreateProspect) {
		this.dateCreateProspect = dateCreateProspect;
	}

	public javax.swing.JTextArea getTexteCommentaire() {
		return texteCommentaire;
	}

	public void setTexteCommentaire(javax.swing.JTextArea texteCommentaire) {
		this.texteCommentaire = texteCommentaire;
	}

	public javax.swing.JTextField getTextNumero() {
		return textNumero;
	}

	public void setTextNumero(javax.swing.JTextField textNumero) {
		this.textNumero = textNumero;
	}

	public JPanel getFrame() {
		return this;

	}

	private javax.swing.JLabel jLabel3;

	public String getNumeroCorrespondant() {
		return numeroCorrespondant;
	}

	public void setNumeroCorrespondant(String numeroCorrespondant) {
		this.numeroCorrespondant = numeroCorrespondant;
	}

	public javax.swing.JButton getButtonAnnuler() {
		return buttonAnnuler;
	}

	public void setButtonAnnuler(javax.swing.JButton buttonAnnuler) {
		this.buttonAnnuler = buttonAnnuler;
	}

	public javax.swing.JButton getButtonValider() {
		return buttonValider;
	}

	public void setButtonValider(javax.swing.JButton buttonValider) {
		this.buttonValider = buttonValider;
	}

	private javax.swing.JLabel jLabel4;
	private javax.swing.JScrollPane jScrollPane1;
	private javax.swing.JTextArea texteCommentaire;
	private javax.swing.JTextField textNumero;
	// End of variables declaration//GEN-END:variables
}
